
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>3.10 检测外部库:Ⅱ. 自定义find模块 · 《CMake Cookbook》中文版</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="陈晓伟 chenxiaowei">
        
        
    
    <link rel="stylesheet" href="../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-pageview-count/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../chapter4/4.0-chinese.html" />
    
    
    <link rel="prev" href="3.9-chinese.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../">
            
                <a href="../../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../preface/preface-chinese.html">
            
                <a href="../preface/preface-chinese.html">
            
                    
                    前言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../chapter0/0.0-chinese.html">
            
                <a href="../chapter0/0.0-chinese.html">
            
                    
                    第0章 配置环境
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../chapter0/0.1-chinese.html">
            
                <a href="../chapter0/0.1-chinese.html">
            
                    
                    0.1 获取代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../chapter0/0.2-chinese.html">
            
                <a href="../chapter0/0.2-chinese.html">
            
                    
                    0.2 Docker镜像
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../chapter0/0.3-chinese.html">
            
                <a href="../chapter0/0.3-chinese.html">
            
                    
                    0.3 安装必要的软件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../chapter0/0.4-chinese.html">
            
                <a href="../chapter0/0.4-chinese.html">
            
                    
                    0.4 测试环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../chapter0/0.5-chinese.html">
            
                <a href="../chapter0/0.5-chinese.html">
            
                    
                    0.5 上报问题并提出改进建议
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../chapter1/1.0-chinese.html">
            
                <a href="../chapter1/1.0-chinese.html">
            
                    
                    第1章 从可执行文件到库
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../chapter1/1.1-chinese.html">
            
                <a href="../chapter1/1.1-chinese.html">
            
                    
                    1.1 将单个源文件编译为可执行文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../chapter1/1.2-chinese.html">
            
                <a href="../chapter1/1.2-chinese.html">
            
                    
                    1.2 切换生成器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../chapter1/1.3-chinese.html">
            
                <a href="../chapter1/1.3-chinese.html">
            
                    
                    1.3 构建和链接静态库和动态库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../chapter1/1.4-chinese.html">
            
                <a href="../chapter1/1.4-chinese.html">
            
                    
                    1.4 用条件句控制编译
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../chapter1/1.5-chinese.html">
            
                <a href="../chapter1/1.5-chinese.html">
            
                    
                    1.5 向用户显示选项
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../chapter1/1.6-chinese.html">
            
                <a href="../chapter1/1.6-chinese.html">
            
                    
                    1.6 指定编译器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="../chapter1/1.7-chinese.html">
            
                <a href="../chapter1/1.7-chinese.html">
            
                    
                    1.7 切换构建类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8" data-path="../chapter1/1.8-chinese.html">
            
                <a href="../chapter1/1.8-chinese.html">
            
                    
                    1.8 设置编译器选项
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.9" data-path="../chapter1/1.9-chinese.html">
            
                <a href="../chapter1/1.9-chinese.html">
            
                    
                    1.9 为语言设定标准
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.10" data-path="../chapter1/1.10-chinese.html">
            
                <a href="../chapter1/1.10-chinese.html">
            
                    
                    1.10 使用控制流
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../chapter2/2.0-chinese.html">
            
                <a href="../chapter2/2.0-chinese.html">
            
                    
                    第2章 检测环境
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../chapter2/2.1-chinese.html">
            
                <a href="../chapter2/2.1-chinese.html">
            
                    
                    2.1 检测操作系统
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../chapter2/2.2-chinese.html">
            
                <a href="../chapter2/2.2-chinese.html">
            
                    
                    2.2 处理与平台相关的源代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../chapter2/2.3-chinese.html">
            
                <a href="../chapter2/2.3-chinese.html">
            
                    
                    2.3 处理与编译器相关的源代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../chapter2/2.4-chinese.html">
            
                <a href="../chapter2/2.4-chinese.html">
            
                    
                    2.4 检测处理器体系结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.5" data-path="../chapter2/2.5-chinese.html">
            
                <a href="../chapter2/2.5-chinese.html">
            
                    
                    2.5 检测处理器指令集
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.6" data-path="../chapter2/2.6-chinese.html">
            
                <a href="../chapter2/2.6-chinese.html">
            
                    
                    2.6 为Eigen库使能向量化
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="3.0-chinese.html">
            
                <a href="3.0-chinese.html">
            
                    
                    第3章 检测外部库和程序
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="3.1-chinese.html">
            
                <a href="3.1-chinese.html">
            
                    
                    3.1 检测Python解释器
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="3.2-chinese.html">
            
                <a href="3.2-chinese.html">
            
                    
                    3.2 检测Python库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="3.3-chinese.html">
            
                <a href="3.3-chinese.html">
            
                    
                    3.3 检测Python模块和包
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="3.4-chinese.html">
            
                <a href="3.4-chinese.html">
            
                    
                    3.4 检测BLAS和LAPACK数学库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="3.5-chinese.html">
            
                <a href="3.5-chinese.html">
            
                    
                    3.5 检测OpenMP的并行环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="3.6-chinese.html">
            
                <a href="3.6-chinese.html">
            
                    
                    3.6 检测MPI的并行环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="3.7-chinese.html">
            
                <a href="3.7-chinese.html">
            
                    
                    3.7 检测Eigen库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" data-path="3.8-chinese.html">
            
                <a href="3.8-chinese.html">
            
                    
                    3.8 检测Boost库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.9" data-path="3.9-chinese.html">
            
                <a href="3.9-chinese.html">
            
                    
                    3.9 检测外部库:Ⅰ. 使用pkg-config
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.6.10" data-path="3.10-chinese.html">
            
                <a href="3.10-chinese.html">
            
                    
                    3.10 检测外部库:Ⅱ. 自定义find模块
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../chapter4/4.0-chinese.html">
            
                <a href="../chapter4/4.0-chinese.html">
            
                    
                    第4章 创建和运行测试
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../chapter4/4.1-chinese.html">
            
                <a href="../chapter4/4.1-chinese.html">
            
                    
                    4.1 创建一个简单的单元测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../chapter4/4.2-chinese.html">
            
                <a href="../chapter4/4.2-chinese.html">
            
                    
                    4.2 使用Catch2库进行单元测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../chapter4/4.3-chinese.html">
            
                <a href="../chapter4/4.3-chinese.html">
            
                    
                    4.3 使用Google Test库进行单元测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="../chapter4/4.4-chinese.html">
            
                <a href="../chapter4/4.4-chinese.html">
            
                    
                    4.4 使用Boost Test进行单元测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.5" data-path="../chapter4/4.5-chinese.html">
            
                <a href="../chapter4/4.5-chinese.html">
            
                    
                    4.5 使用动态分析来检测内存缺陷
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.6" data-path="../chapter4/4.6-chinese.html">
            
                <a href="../chapter4/4.6-chinese.html">
            
                    
                    4.6 预期测试失败
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.7" data-path="../chapter4/4.7-chinese.html">
            
                <a href="../chapter4/4.7-chinese.html">
            
                    
                    4.7 使用超时测试运行时间过长的测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.8" data-path="../chapter4/4.8-chinese.html">
            
                <a href="../chapter4/4.8-chinese.html">
            
                    
                    4.8 并行测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.9" data-path="../chapter4/4.9-chinese.html">
            
                <a href="../chapter4/4.9-chinese.html">
            
                    
                    4.9 运行测试子集
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.10" data-path="../chapter4/4.10-chinese.html">
            
                <a href="../chapter4/4.10-chinese.html">
            
                    
                    4.10 使用测试固件
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../chapter5/5.0-chinese.html">
            
                <a href="../chapter5/5.0-chinese.html">
            
                    
                    第5章 配置时和构建时的操作
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../chapter5/5.1-chinese.html">
            
                <a href="../chapter5/5.1-chinese.html">
            
                    
                    5.1 使用平台无关的文件操作
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../chapter5/5.2-chinese.html">
            
                <a href="../chapter5/5.2-chinese.html">
            
                    
                    5.2 配置时运行自定义命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../chapter5/5.3-chinese.html">
            
                <a href="../chapter5/5.3-chinese.html">
            
                    
                    5.3 构建时运行自定义命令:Ⅰ. 使用add_custom_command
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="../chapter5/5.4-chinese.html">
            
                <a href="../chapter5/5.4-chinese.html">
            
                    
                    5.4 构建时运行自定义命令:Ⅱ. 使用add_custom_target
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.5" data-path="../chapter5/5.5-chinese.html">
            
                <a href="../chapter5/5.5-chinese.html">
            
                    
                    5.5 构建时为特定目标运行自定义命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.6" data-path="../chapter5/5.6-chinese.html">
            
                <a href="../chapter5/5.6-chinese.html">
            
                    
                    5.6 探究编译和链接命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.7" data-path="../chapter5/5.7-chinese.html">
            
                <a href="../chapter5/5.7-chinese.html">
            
                    
                    5.7 探究编译器标志命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.8" data-path="../chapter5/5.8-chinese.html">
            
                <a href="../chapter5/5.8-chinese.html">
            
                    
                    5.8 探究可执行命令
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.9" data-path="../chapter5/5.9-chinese.html">
            
                <a href="../chapter5/5.9-chinese.html">
            
                    
                    5.9 使用生成器表达式微调配置和编译
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../chapter6/6.0-chinese.html">
            
                <a href="../chapter6/6.0-chinese.html">
            
                    
                    第6章 生成源码
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../chapter6/6.1-chinese.html">
            
                <a href="../chapter6/6.1-chinese.html">
            
                    
                    6.1 配置时生成源码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../chapter6/6.2-chinese.html">
            
                <a href="../chapter6/6.2-chinese.html">
            
                    
                    6.2 使用Python在配置时生成源码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.3" data-path="../chapter6/6.3-chinese.html">
            
                <a href="../chapter6/6.3-chinese.html">
            
                    
                    6.3 构建时使用Python生成源码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.4" data-path="../chapter6/6.4-chinese.html">
            
                <a href="../chapter6/6.4-chinese.html">
            
                    
                    6.4 记录项目版本信息以便报告
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.5" data-path="../chapter6/6.5-chinese.html">
            
                <a href="../chapter6/6.5-chinese.html">
            
                    
                    6.5 从文件中记录项目版本
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.6" data-path="../chapter6/6.6-chinese.html">
            
                <a href="../chapter6/6.6-chinese.html">
            
                    
                    6.6 配置时记录Git Hash值
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.7" data-path="../chapter6/6.7-chinese.html">
            
                <a href="../chapter6/6.7-chinese.html">
            
                    
                    6.7 构建时记录Git Hash值
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../chapter7/7.0-chinese.html">
            
                <a href="../chapter7/7.0-chinese.html">
            
                    
                    第7章 构建项目
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../chapter7/7.1-chinese.html">
            
                <a href="../chapter7/7.1-chinese.html">
            
                    
                    7.1 使用函数和宏重用代码
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="../chapter7/7.2-chinese.html">
            
                <a href="../chapter7/7.2-chinese.html">
            
                    
                    7.2 将CMake源代码分成模块
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3" data-path="../chapter7/7.3-chinese.html">
            
                <a href="../chapter7/7.3-chinese.html">
            
                    
                    7.3 编写函数来测试和设置编译器标志
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.4" data-path="../chapter7/7.4-chinese.html">
            
                <a href="../chapter7/7.4-chinese.html">
            
                    
                    7.4 用指定参数定义函数或宏
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.5" data-path="../chapter7/7.5-chinese.html">
            
                <a href="../chapter7/7.5-chinese.html">
            
                    
                    7.5 重新定义函数和宏
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.6" data-path="../chapter7/7.6-chinese.html">
            
                <a href="../chapter7/7.6-chinese.html">
            
                    
                    7.6 使用废弃函数、宏和变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.7" data-path="../chapter7/7.7-chinese.html">
            
                <a href="../chapter7/7.7-chinese.html">
            
                    
                    7.7 add_subdirectory的限定范围
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.8" data-path="../chapter7/7.8-chinese.html">
            
                <a href="../chapter7/7.8-chinese.html">
            
                    
                    7.8 使用target_sources避免全局变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.9" data-path="../chapter7/7.9-chinese.html">
            
                <a href="../chapter7/7.9-chinese.html">
            
                    
                    7.9 组织Fortran项目
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="../chapter8/8.0-chinese.html">
            
                <a href="../chapter8/8.0-chinese.html">
            
                    
                    第8章 超级构建模式
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="../chapter8/8.1-chinese.html">
            
                <a href="../chapter8/8.1-chinese.html">
            
                    
                    8.1 使用超级构建模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.2" data-path="../chapter8/8.2-chinese.html">
            
                <a href="../chapter8/8.2-chinese.html">
            
                    
                    8.2 使用超级构建管理依赖项:Ⅰ.Boost库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.3" data-path="../chapter8/8.3-chinese.html">
            
                <a href="../chapter8/8.3-chinese.html">
            
                    
                    8.3 使用超级构建管理依赖项:Ⅱ.FFTW库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.4" data-path="../chapter8/8.4-chinese.html">
            
                <a href="../chapter8/8.4-chinese.html">
            
                    
                    8.4 使用超级构建管理依赖项:Ⅲ.Google Test框架
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.5" data-path="../chapter8/8.5-chinese.html">
            
                <a href="../chapter8/8.5-chinese.html">
            
                    
                    8.5 使用超级构建支持项目
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../chapter9/9.0-chinese.html">
            
                <a href="../chapter9/9.0-chinese.html">
            
                    
                    第9章 语言混合项目
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.12.1" data-path="../chapter9/9.1-chinese.html">
            
                <a href="../chapter9/9.1-chinese.html">
            
                    
                    9.1 使用C/C++库构建Fortran项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.2" data-path="../chapter9/9.2-chinese.html">
            
                <a href="../chapter9/9.2-chinese.html">
            
                    
                    9.2 使用Fortran库构建C/C++项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.3" data-path="../chapter9/9.3-chinese.html">
            
                <a href="../chapter9/9.3-chinese.html">
            
                    
                    9.3 使用Cython构建C++和Python项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.4" data-path="../chapter9/9.4-chinese.html">
            
                <a href="../chapter9/9.4-chinese.html">
            
                    
                    9.4 使用Boost.Python构建C++和Python项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.5" data-path="../chapter9/9.5-chinese.html">
            
                <a href="../chapter9/9.5-chinese.html">
            
                    
                    9.5 使用pybind11构建C++和Python项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.6" data-path="../chapter9/9.6-chinese.html">
            
                <a href="../chapter9/9.6-chinese.html">
            
                    
                    9.6 使用Python CFFI混合C，C++，Fortran和Python
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../chapter10/10.0-chinese.html">
            
                <a href="../chapter10/10.0-chinese.html">
            
                    
                    第10章 编写安装程序
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1" data-path="../chapter10/10.1-chinese.html">
            
                <a href="../chapter10/10.1-chinese.html">
            
                    
                    10.1 安装项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.2" data-path="../chapter10/10.2-chinese.html">
            
                <a href="../chapter10/10.2-chinese.html">
            
                    
                    10.2 生成输出头文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.3" data-path="../chapter10/10.3-chinese.html">
            
                <a href="../chapter10/10.3-chinese.html">
            
                    
                    10.3 输出目标
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.4" data-path="../chapter10/10.4-chinese.html">
            
                <a href="../chapter10/10.4-chinese.html">
            
                    
                    10.4 安装超级构建
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="../chapter11/11.0-chinese.html">
            
                <a href="../chapter11/11.0-chinese.html">
            
                    
                    第11章 打包项目
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.14.1" data-path="../chapter11/11.1-chinese.html">
            
                <a href="../chapter11/11.1-chinese.html">
            
                    
                    11.1 生成源代码和二进制包
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.2" data-path="../chapter11/11.2-chinese.html">
            
                <a href="../chapter11/11.2-chinese.html">
            
                    
                    11.2 通过PyPI发布使用CMake/pybind11构建的C++/Python项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.3" data-path="../chapter11/11.3-chinese.html">
            
                <a href="../chapter11/11.3-chinese.html">
            
                    
                    11.3 通过PyPI发布使用CMake/CFFI构建C/Fortran/Python项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.4" data-path="../chapter11/11.4-chinese.html">
            
                <a href="../chapter11/11.4-chinese.html">
            
                    
                    11.4 以Conda包的形式发布一个简单的项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14.5" data-path="../chapter11/11.5-chinese.html">
            
                <a href="../chapter11/11.5-chinese.html">
            
                    
                    11.5 将Conda包作为依赖项发布给项目
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="../chapter12/12.0-chinese.html">
            
                <a href="../chapter12/12.0-chinese.html">
            
                    
                    第12章 构建文档
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.15.1" data-path="../chapter12/12.1-chinese.html">
            
                <a href="../chapter12/12.1-chinese.html">
            
                    
                    12.1 使用Doxygen构建文档
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.2" data-path="../chapter12/12.2-chinese.html">
            
                <a href="../chapter12/12.2-chinese.html">
            
                    
                    12.2 使用Sphinx构建文档
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15.3" data-path="../chapter12/12.3-chinese.html">
            
                <a href="../chapter12/12.3-chinese.html">
            
                    
                    12.3 结合Doxygen和Sphinx
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="../chapter13/13.0-chinese.html">
            
                <a href="../chapter13/13.0-chinese.html">
            
                    
                    第13章 选择生成器和交叉编译
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.16.1" data-path="../chapter13/13.1-chinese.html">
            
                <a href="../chapter13/13.1-chinese.html">
            
                    
                    13.1 使用CMake构建Visual Studio 2017项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16.2" data-path="../chapter13/13.2-chinese.html">
            
                <a href="../chapter13/13.2-chinese.html">
            
                    
                    13.2 交叉编译hello world示例
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16.3" data-path="../chapter13/13.3-chinese.html">
            
                <a href="../chapter13/13.3-chinese.html">
            
                    
                    13.3 使用OpenMP并行化交叉编译Windows二进制文件
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="../chapter14/14.0-chinese.html">
            
                <a href="../chapter14/14.0-chinese.html">
            
                    
                    第14章 测试面板
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.17.1" data-path="../chapter14/14.1-chinese.html">
            
                <a href="../chapter14/14.1-chinese.html">
            
                    
                    14.1 将测试部署到CDash
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.2" data-path="../chapter14/14.2-chinese.html">
            
                <a href="../chapter14/14.2-chinese.html">
            
                    
                    14.2 CDash显示测试覆盖率
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.3" data-path="../chapter14/14.3-chinese.html">
            
                <a href="../chapter14/14.3-chinese.html">
            
                    
                    14.3 使用AddressSanifier向CDash报告内存缺陷
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17.4" data-path="../chapter14/14.4-chinese.html">
            
                <a href="../chapter14/14.4-chinese.html">
            
                    
                    14.4 使用ThreadSaniiser向CDash报告数据争用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="../chapter15/15.0-chinese.html">
            
                <a href="../chapter15/15.0-chinese.html">
            
                    
                    第15章 使用CMake构建已有项目
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.18.1" data-path="../chapter15/15.1-chinese.html">
            
                <a href="../chapter15/15.1-chinese.html">
            
                    
                    15.1 如何开始迁移项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.2" data-path="../chapter15/15.2-chinese.html">
            
                <a href="../chapter15/15.2-chinese.html">
            
                    
                    15.2 生成文件并编写平台检查
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.3" data-path="../chapter15/15.3-chinese.html">
            
                <a href="../chapter15/15.3-chinese.html">
            
                    
                    15.3 检测所需的链接和依赖关系
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.4" data-path="../chapter15/15.4-chinese.html">
            
                <a href="../chapter15/15.4-chinese.html">
            
                    
                    15.4 复制编译标志
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.5" data-path="../chapter15/15.5-chinese.html">
            
                <a href="../chapter15/15.5-chinese.html">
            
                    
                    15.5 移植测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.6" data-path="../chapter15/15.6-chinese.html">
            
                <a href="../chapter15/15.6-chinese.html">
            
                    
                    15.6 移植安装目标
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.7" data-path="../chapter15/15.7-chinese.html">
            
                <a href="../chapter15/15.7-chinese.html">
            
                    
                    15.7 进一步迁移的措施
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18.8" data-path="../chapter15/15.8-chinese.html">
            
                <a href="../chapter15/15.8-chinese.html">
            
                    
                    15.8 项目转换为CMake的常见问题
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="../chapter16/16.0-chinese.html">
            
                <a href="../chapter16/16.0-chinese.html">
            
                    
                    第16章 可能感兴趣的书
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.19.1" data-path="../chapter16/16.1-chinese.html">
            
                <a href="../chapter16/16.1-chinese.html">
            
                    
                    16.1 留下评论——让其他读者知道你的想法
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="http://www.bczl.xyz/" target="blank" class="gitbook-link">
            编程之路
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../.." >3.10 检测外部库:Ⅱ. 自定义find模块</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="310-&#x68C0;&#x6D4B;&#x5916;&#x90E8;&#x5E93;&#x2171;-&#x81EA;&#x5B9A;&#x4E49;find&#x6A21;&#x5757;">3.10 &#x68C0;&#x6D4B;&#x5916;&#x90E8;&#x5E93;:&#x2161;. &#x81EA;&#x5B9A;&#x4E49;find&#x6A21;&#x5757;</h1>
<p><strong>NOTE</strong>:<em>&#x6B64;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x53EF;&#x4EE5;&#x5728; <a href="https://github.com/dev-cafe/cmake-cookbook/tree/v1.0/chapter-03/recipe-10" target="_blank">https://github.com/dev-cafe/cmake-cookbook/tree/v1.0/chapter-03/recipe-10</a> &#x4E2D;&#x627E;&#x5230;&#xFF0C;&#x5305;&#x542B;&#x4E00;&#x4E2A;C&#x7684;&#x793A;&#x4F8B;&#x3002;&#x8BE5;&#x793A;&#x4F8B;&#x5728;CMake 3.5&#x7248;(&#x6216;&#x66F4;&#x9AD8;&#x7248;&#x672C;)&#x4E2D;&#x662F;&#x6709;&#x6548;&#x7684;&#xFF0C;&#x5E76;&#x4E14;&#x5DF2;&#x7ECF;&#x5728;GNU/Linux&#x3001;macOS&#x548C;Windows&#x4E0A;&#x8FDB;&#x884C;&#x8FC7;&#x6D4B;&#x8BD5;&#x3002;</em></p>
<p>&#x6B64;&#x793A;&#x4F8B;&#x8865;&#x5145;&#x4E86;&#x4E0A;&#x4E00;&#x8282;&#x7684;&#x793A;&#x4F8B;&#xFF0C;&#x6211;&#x4EEC;&#x5C06;&#x5C55;&#x793A;&#x5982;&#x4F55;&#x7F16;&#x5199;&#x4E00;&#x4E2A;<code>find</code>&#x6A21;&#x5757;&#x6765;&#x5B9A;&#x4F4D;&#x7CFB;&#x7EDF;&#x4E0A;&#x7684;ZeroMQ&#x6D88;&#x606F;&#x5E93;&#xFF0C;&#x4EE5;&#x4FBF;&#x80FD;&#x591F;&#x5728;&#x975E;Unix&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x4E0A;&#x68C0;&#x6D4B;&#x8BE5;&#x5E93;&#x3002;&#x6211;&#x4EEC;&#x91CD;&#x7528;&#x670D;&#x52A1;&#x5668;-&#x5BA2;&#x6237;&#x7AEF;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x3002;</p>
<h2 id="&#x5982;&#x4F55;&#x5B9E;&#x65BD;">&#x5982;&#x4F55;&#x5B9E;&#x65BD;</h2>
<p>&#x8FD9;&#x662F;&#x4E00;&#x4E2A;C&#x9879;&#x76EE;&#xFF0C;&#x4F7F;&#x7528;C99&#x6807;&#x51C6;&#xFF0C;&#x5E76;&#x9010;&#x6B65;&#x6784;&#x5EFA;CMakeLists.txt&#x6587;&#x4EF6;:</p>
<ol>
<li><p>&#x58F0;&#x660E;&#x4E00;&#x4E2A;C&#x9879;&#x76EE;&#xFF0C;&#x5E76;&#x8981;&#x6C42;&#x7B26;&#x5408;C99&#x6807;&#x51C6;:</p>
<pre><code class="lang-cmake"><span class="hljs-keyword">cmake_minimum_required</span>(VERSION <span class="hljs-number">3.5</span> FATAL_ERROR)

<span class="hljs-keyword">project</span>(recipe-<span class="hljs-number">10</span> LANGUAGES C)

<span class="hljs-keyword">set</span>(CMAKE_C_STANDARD <span class="hljs-number">99</span>)
<span class="hljs-keyword">set</span>(CMAKE_C_EXTENSIONS <span class="hljs-keyword">OFF</span>)
<span class="hljs-keyword">set</span>(CMAKE_C_STANDARD_REQUIRED <span class="hljs-keyword">ON</span>)
</code></pre>
</li>
<li><p>&#x5C06;&#x5F53;&#x524D;&#x6E90;&#x76EE;&#x5F55;<code>CMAKE_CURRENT_SOURCE_DIR</code>&#xFF0C;&#x6DFB;&#x52A0;&#x5230;CMake&#x5C06;&#x67E5;&#x627E;&#x6A21;&#x5757;&#x7684;&#x8DEF;&#x5F84;&#x5217;&#x8868;<code>CMAKE_MODULE_PATH</code>&#x4E2D;&#x3002;&#x8FD9;&#x6837;CMake&#x5C31;&#x53EF;&#x4EE5;&#x627E;&#x5230;&#xFF0C;&#x6211;&#x4EEC;&#x81EA;&#x5B9A;&#x4E49;&#x7684;<code>FindZeroMQ.cmake</code>&#x6A21;&#x5757;:</p>
<pre><code class="lang-cmake">list(APPEND CMAKE_MODULE_PATH <span class="hljs-variable">${CMAKE_CURRENT_SOURCE_DIR}</span>)
</code></pre>
</li>
<li><p>&#x73B0;&#x5728;<code>FindZeroMQ.cmake</code>&#x6A21;&#x5757;&#x662F;&#x53EF;&#x7528;&#x7684;&#xFF0C;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x8FD9;&#x4E2A;&#x6A21;&#x5757;&#x6765;&#x641C;&#x7D22;&#x9879;&#x76EE;&#x6240;&#x9700;&#x7684;&#x4F9D;&#x8D56;&#x9879;&#x3002;&#x7531;&#x4E8E;&#x6211;&#x4EEC;&#x6CA1;&#x6709;&#x4F7F;&#x7528;<code>QUIET</code>&#x9009;&#x9879;&#x6765;&#x67E5;&#x627E;<code>find_package</code>&#xFF0C;&#x6240;&#x4EE5;&#x5F53;&#x627E;&#x5230;&#x5E93;&#x65F6;&#xFF0C;&#x72B6;&#x6001;&#x6D88;&#x606F;&#x5C06;&#x81EA;&#x52A8;&#x6253;&#x5370;:</p>
<pre><code class="lang-cmake"><span class="hljs-keyword">find_package</span>(ZeroMQ REQUIRED)
</code></pre>
</li>
<li><p>&#x6211;&#x4EEC;&#x7EE7;&#x7EED;&#x6DFB;&#x52A0;<code>hwserver</code>&#x53EF;&#x6267;&#x884C;&#x76EE;&#x6807;&#x3002;&#x5934;&#x6587;&#x4EF6;&#x5305;&#x542B;&#x76EE;&#x5F55;&#x548C;&#x94FE;&#x63A5;&#x5E93;&#x662F;&#x4F7F;&#x7528;<code>find_package</code>&#x547D;&#x4EE4;&#x6210;&#x529F;&#x540E;&#xFF0C;&#x4F7F;&#x7528;<code>ZeroMQ_INCLUDE_DIRS</code>&#x548C;<code>ZeroMQ_LIBRARIES</code>&#x53D8;&#x91CF;&#x8FDB;&#x884C;&#x6307;&#x5B9A;&#x7684;:</p>
<pre><code class="lang-cmake"><span class="hljs-keyword">add_executable</span>(hwserver hwserver.c)
target_include_directories(hwserver
  PRIVATE
      <span class="hljs-variable">${ZeroMQ_INCLUDE_DIRS}</span>
  )
<span class="hljs-keyword">target_link_libraries</span>(hwserver
  PRIVATE
      <span class="hljs-variable">${ZeroMQ_LIBRARIES}</span>
  )
</code></pre>
</li>
<li><p>&#x6700;&#x540E;&#xFF0C;&#x6211;&#x4EEC;&#x5BF9;<code>hwclient</code>&#x53EF;&#x6267;&#x884C;&#x76EE;&#x6807;&#x6267;&#x884C;&#x76F8;&#x540C;&#x7684;&#x64CD;&#x4F5C;:</p>
<pre><code class="lang-cmake"><span class="hljs-keyword">add_executable</span>(hwclient hwclient.c)
target_include_directories(hwclient
  PRIVATE
      <span class="hljs-variable">${ZeroMQ_INCLUDE_DIRS}</span>
  )
<span class="hljs-keyword">target_link_libraries</span>(hwclient
  PRIVATE
      <span class="hljs-variable">${ZeroMQ_LIBRARIES}</span>
  )
</code></pre>
</li>
</ol>
<p>&#x6B64;&#x793A;&#x4F8B;&#x7684;&#x4E3B;<code>CMakeLists.txt</code>&#x5728;&#x4F7F;&#x7528;<code>FindZeroMQ.cmake</code>&#x65F6;&#xFF0C;&#x4E0E;&#x524D;&#x4E00;&#x4E2A;&#x793A;&#x4F8B;&#x4E2D;&#x4F7F;&#x7528;&#x7684;<code>CMakeLists.txt</code>&#x4E0D;&#x540C;&#x3002;&#x8FD9;&#x4E2A;&#x6A21;&#x5757;&#x4F7F;&#x7528;<code>find_path</code>&#x548C;<code>find_library</code> CMake&#x5185;&#x7F6E;&#x547D;&#x4EE4;&#xFF0C;&#x641C;&#x7D22;ZeroMQ&#x5934;&#x6587;&#x4EF6;&#x548C;&#x5E93;&#xFF0C;&#x5E76;&#x4F7F;&#x7528;<code>find_package_handle_standard_args</code>&#x8BBE;&#x7F6E;&#x76F8;&#x5173;&#x53D8;&#x91CF;&#xFF0C;&#x5C31;&#x50CF;&#x6211;&#x4EEC;&#x5728;&#x7B2C;3&#x8282;&#x4E2D;&#x505A;&#x7684;&#x90A3;&#x6837;&#x3002;</p>
<ol>
<li><p><code>FindZeroMQ.cmake</code>&#x4E2D;&#xFF0C;&#x68C0;&#x67E5;&#x4E86;<code>ZeroMQ_ROOT</code>&#x53D8;&#x91CF;&#x662F;&#x5426;&#x8BBE;&#x7F6E;&#x3002;&#x6B64;&#x53D8;&#x91CF;&#x53EF;&#x7528;&#x4E8E;ZeroMQ&#x5E93;&#x7684;&#x68C0;&#x6D4B;&#xFF0C;&#x5E76;&#x5F15;&#x5BFC;&#x5230;&#x81EA;&#x5B9A;&#x4E49;&#x5B89;&#x88C5;&#x76EE;&#x5F55;&#x3002;&#x7528;&#x6237;&#x53EF;&#x80FD;&#x8BBE;&#x7F6E;&#x4E86;<code>ZeroMQ_ROOT</code>&#x4F5C;&#x4E3A;&#x73AF;&#x5883;&#x53D8;&#x91CF;&#xFF0C;&#x6211;&#x4EEC;&#x4E5F;&#x4F1A;&#x8FDB;&#x884C;&#x68C0;&#x67E5;&#x4E86;:</p>
<pre><code class="lang-cmake"><span class="hljs-keyword">if</span>(NOT ZeroMQ_ROOT)
    <span class="hljs-keyword">set</span>(ZeroMQ_ROOT <span class="hljs-string">&quot;$ENV{ZeroMQ_ROOT}&quot;</span>)
<span class="hljs-keyword">endif</span>()
</code></pre>
</li>
<li><p>&#x7136;&#x540E;&#xFF0C;&#x641C;&#x7D22;&#x7CFB;&#x7EDF;&#x4E0A;<code>zmq.h</code>&#x5934;&#x6587;&#x4EF6;&#x7684;&#x4F4D;&#x7F6E;&#x3002;&#x8FD9;&#x662F;&#x57FA;&#x4E8E;<code>_ZeroMQ_ROOT</code>&#x53D8;&#x91CF;&#x548C;<code>find_path</code>&#x547D;&#x4EE4;&#x8FDB;&#x884C;&#x7684;:</p>
<pre><code class="lang-cmake"><span class="hljs-keyword">if</span>(NOT ZeroMQ_ROOT)
    <span class="hljs-keyword">find_path</span>(_ZeroMQ_ROOT NAMES <span class="hljs-keyword">include</span>/zmq.h)
<span class="hljs-keyword">else</span>()
    <span class="hljs-keyword">set</span>(_ZeroMQ_ROOT <span class="hljs-string">&quot;${ZeroMQ_ROOT}&quot;</span>)
<span class="hljs-keyword">endif</span>()

<span class="hljs-keyword">find_path</span>(ZeroMQ_INCLUDE_DIRS NAMES zmq.h HINTS <span class="hljs-variable">${_ZeroMQ_ROOT}</span>/<span class="hljs-keyword">include</span>)
</code></pre>
</li>
<li><p>&#x5982;&#x679C;&#x6210;&#x529F;&#x627E;&#x5230;&#x5934;&#x6587;&#x4EF6;&#xFF0C;&#x5219;&#x5C06;<code>ZeroMQ_INCLUDE_DIRS</code>&#x8BBE;&#x7F6E;&#x4E3A;&#x5176;&#x4F4D;&#x7F6E;&#x3002;&#x6211;&#x4EEC;&#x7EE7;&#x7EED;&#x901A;&#x8FC7;&#x4F7F;&#x7528;&#x5B57;&#x7B26;&#x4E32;&#x64CD;&#x4F5C;&#x548C;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#xFF0C;&#x5BFB;&#x627E;&#x76F8;&#x5E94;&#x7248;&#x672C;&#x7684;ZeroMQ&#x5E93;:</p>
<pre><code class="lang-cmake"><span class="hljs-keyword">set</span>(_ZeroMQ_H <span class="hljs-variable">${ZeroMQ_INCLUDE_DIRS}</span>/zmq.h)

<span class="hljs-keyword">function</span>(_zmqver_EXTRACT _ZeroMQ_VER_COMPONENT _ZeroMQ_VER_OUTPUT)
<span class="hljs-keyword">set</span>(CMAKE_MATCH_1 <span class="hljs-string">&quot;0&quot;</span>)
<span class="hljs-keyword">set</span>(_ZeroMQ_expr <span class="hljs-string">&quot;^[ \\t]*#define[ \\t]+${_ZeroMQ_VER_COMPONENT}[ \\t]+([0-9]+)$&quot;</span>)
file(STRINGS <span class="hljs-string">&quot;${_ZeroMQ_H}&quot;</span> _ZeroMQ_ver REGEX <span class="hljs-string">&quot;${_ZeroMQ_expr}&quot;</span>)
<span class="hljs-keyword">string</span>(REGEX MATCH <span class="hljs-string">&quot;${_ZeroMQ_expr}&quot;</span> ZeroMQ_ver <span class="hljs-string">&quot;${_ZeroMQ_ver}&quot;</span>)
<span class="hljs-keyword">set</span>(<span class="hljs-variable">${_ZeroMQ_VER_OUTPUT}</span> <span class="hljs-string">&quot;${CMAKE_MATCH_1}&quot;</span> PARENT_SCOPE)
<span class="hljs-keyword">endfunction</span>()

_zmqver_EXTRACT(<span class="hljs-string">&quot;ZMQ_VERSION_MAJOR&quot;</span> ZeroMQ_VERSION_MAJOR)
_zmqver_EXTRACT(<span class="hljs-string">&quot;ZMQ_VERSION_MINOR&quot;</span> ZeroMQ_VERSION_MINOR)
_zmqver_EXTRACT(<span class="hljs-string">&quot;ZMQ_VERSION_PATCH&quot;</span> ZeroMQ_VERSION_PATCH)
</code></pre>
</li>
<li><p>&#x7136;&#x540E;&#xFF0C;&#x4E3A;<code>find_package_handle_standard_args</code>&#x51C6;&#x5907;<code>ZeroMQ_VERSION</code>&#x53D8;&#x91CF;:</p>
<pre><code class="lang-cmake"><span class="hljs-keyword">if</span>(ZeroMQ_FIND_VERSION_COUNT <span class="hljs-keyword">GREATER</span> <span class="hljs-number">2</span>)
    <span class="hljs-keyword">set</span>(ZeroMQ_VERSION <span class="hljs-string">&quot;${ZeroMQ_VERSION_MAJOR}.${ZeroMQ_VERSION_MINOR}.${ZeroMQ_VERSION_PATCH}&quot;</span>)
<span class="hljs-keyword">else</span>()
    <span class="hljs-keyword">set</span>(ZeroMQ_VERSION <span class="hljs-string">&quot;${ZeroMQ_VERSION_MAJOR}.${ZeroMQ_VERSION_MINOR}&quot;</span>)
<span class="hljs-keyword">endif</span>()
</code></pre>
</li>
<li><p>&#x4F7F;&#x7528;<code>find_library</code>&#x547D;&#x4EE4;&#x641C;&#x7D22;ZeroMQ&#x5E93;&#x3002;&#x56E0;&#x4E3A;&#x5E93;&#x7684;&#x547D;&#x540D;&#x6709;&#x6240;&#x4E0D;&#x540C;&#xFF0C;&#x8FD9;&#x91CC;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x533A;&#x5206;Unix&#x7684;&#x5E73;&#x53F0;&#x548C;Windows&#x5E73;&#x53F0;:</p>
<pre><code class="lang-cmake"><span class="hljs-keyword">if</span>(NOT <span class="hljs-variable">${CMAKE_C_PLATFORM_ID}</span> <span class="hljs-keyword">STREQUAL</span> <span class="hljs-string">&quot;Windows&quot;</span>)
  <span class="hljs-keyword">find_library</span>(ZeroMQ_LIBRARIES
    NAMES
        zmq
    HINTS
      <span class="hljs-variable">${_ZeroMQ_ROOT}</span>/lib
      <span class="hljs-variable">${_ZeroMQ_ROOT}</span>/lib/x86_64-linux-gnu
    )
<span class="hljs-keyword">else</span>()
  <span class="hljs-keyword">find_library</span>(ZeroMQ_LIBRARIES
    NAMES
        libzmq
      <span class="hljs-string">&quot;libzmq-mt-${ZeroMQ_VERSION_MAJOR}_${ZeroMQ_VERSION_MINOR}_${ZeroMQ_VERSION_PATCH}&quot;</span>
      <span class="hljs-string">&quot;libzmq-${CMAKE_VS_PLATFORM_TOOLSET}-mt-${ZeroMQ_VERSION_MAJOR}_${ZeroMQ_VERSION_MINOR}_${ZeroMQ_VERSION_PATCH}&quot;</span>
      libzmq_d
      <span class="hljs-string">&quot;libzmq-mt-gd-${ZeroMQ_VERSION_MAJOR}_${ZeroMQ_VERSION_MINOR}_${ZeroMQ_VERSION_PATCH}&quot;</span>
      <span class="hljs-string">&quot;libzmq-${CMAKE_VS_PLATFORM_TOOLSET}-mt-gd-${ZeroMQ_VERSION_MAJOR}_${ZeroMQ_VERSION_MINOR}_${ZeroMQ_VERSION_PATCH}&quot;</span>
    HINTS
        <span class="hljs-variable">${_ZeroMQ_ROOT}</span>/lib
    )
<span class="hljs-keyword">endif</span>()
</code></pre>
</li>
<li><p>&#x6700;&#x540E;&#xFF0C;&#x5305;&#x542B;&#x4E86;&#x6807;&#x51C6;<code>FindPackageHandleStandardArgs.cmake</code>&#xFF0C;&#x5E76;&#x8C03;&#x7528;&#x76F8;&#x5E94;&#x7684;CMake&#x547D;&#x4EE4;&#x3002;&#x5982;&#x679C;&#x627E;&#x5230;&#x6240;&#x6709;&#x9700;&#x8981;&#x7684;&#x53D8;&#x91CF;&#xFF0C;&#x5E76;&#x4E14;&#x7248;&#x672C;&#x5339;&#x914D;&#xFF0C;&#x5219;&#x5C06;<code>ZeroMQ_FOUND</code>&#x53D8;&#x91CF;&#x8BBE;&#x7F6E;&#x4E3A;<code>TRUE</code>:</p>
<pre><code class="lang-cmake"><span class="hljs-keyword">include</span>(FindPackageHandleStandardArgs)

find_package_handle_standard_args(ZeroMQ
  FOUND_VAR
      ZeroMQ_FOUND
  REQUIRED_VARS
  ZeroMQ_INCLUDE_DIRS
  ZeroMQ_LIBRARIES
  VERSION_VAR
  ZeroMQ_VERSION
  )
</code></pre>
</li>
</ol>
<p><strong>NOTE</strong>:<em>&#x521A;&#x624D;&#x63CF;&#x8FF0;&#x7684;<code>FindZeroMQ.cmake</code>&#x6A21;&#x5757;&#x5DF2;&#x7ECF;&#x5728; <a href="https://github.com/zeromq/azmq/blob/master/config/FindZeroMQ.cmake" target="_blank">https://github.com/zeromq/azmq/blob/master/config/FindZeroMQ.cmake</a> &#x4E0A;&#x8FDB;&#x884C;&#x4E86;&#x4FEE;&#x6539;&#x3002;</em></p>
<h2 id="&#x5DE5;&#x4F5C;&#x539F;&#x7406;">&#x5DE5;&#x4F5C;&#x539F;&#x7406;</h2>
<p><code>find-module</code>&#x901A;&#x5E38;&#x9075;&#x5FAA;&#x7279;&#x5B9A;&#x7684;&#x6A21;&#x5F0F;:</p>
<ol>
<li><p>&#x68C0;&#x67E5;&#x7528;&#x6237;&#x662F;&#x5426;&#x4E3A;&#x6240;&#x9700;&#x7684;&#x5305;&#x63D0;&#x4F9B;&#x4E86;&#x81EA;&#x5B9A;&#x4E49;&#x4F4D;&#x7F6E;&#x3002;</p>
</li>
<li><p>&#x4F7F;&#x7528;<code>find_</code>&#x5BB6;&#x65CF;&#x4E2D;&#x7684;&#x547D;&#x4EE4;&#x641C;&#x7D22;&#x6240;&#x9700;&#x5305;&#x7684;&#x5FC5;&#x9700;&#x7EC4;&#x4EF6;&#xFF0C;&#x5373;&#x5934;&#x6587;&#x4EF6;&#x3001;&#x5E93;&#x3001;&#x53EF;&#x6267;&#x884C;&#x7A0B;&#x5E8F;&#x7B49;&#x7B49;&#x3002;&#x6211;&#x4EEC;&#x4F7F;&#x7528;<code>find_path</code>&#x67E5;&#x627E;&#x5934;&#x6587;&#x4EF6;&#x7684;&#x5B8C;&#x6574;&#x8DEF;&#x5F84;&#xFF0C;&#x5E76;&#x4F7F;&#x7528;<code>find_library</code>&#x67E5;&#x627E;&#x5E93;&#x3002;CMake&#x8FD8;&#x63D0;&#x4F9B;<code>find_file</code>&#x3001;<code>find_program</code>&#x548C;<code>find_package</code>&#x3002;&#x8FD9;&#x4E9B;&#x547D;&#x4EE4;&#x7684;&#x7B7E;&#x540D;&#x5982;&#x4E0B;:</p>
<pre><code class="lang-cmake"><span class="hljs-keyword">find_path</span>(&lt;VAR&gt; NAMES name PATHS paths)
</code></pre>
</li>
<li><p>&#x5982;&#x679C;&#x641C;&#x7D22;&#x6210;&#x529F;&#xFF0C;<code>&lt;VAR&gt;</code>&#x5C06;&#x4FDD;&#x5B58;&#x641C;&#x7D22;&#x7ED3;&#x679C;&#xFF1B;&#x5982;&#x679C;&#x641C;&#x7D22;&#x5931;&#x8D25;&#xFF0C;&#x5219;&#x4F1A;&#x8BBE;&#x7F6E;&#x4E3A;<code>&lt;VAR&gt;-NOTFOUND</code>&#x3002;<code>NAMES</code>&#x548C;<code>PATHS</code>&#x5206;&#x522B;&#x662F;CMake&#x5E94;&#x8BE5;&#x67E5;&#x627E;&#x7684;&#x6587;&#x4EF6;&#x7684;&#x540D;&#x79F0;&#x548C;&#x641C;&#x7D22;&#x5E94;&#x8BE5;&#x6307;&#x5411;&#x7684;&#x8DEF;&#x5F84;&#x3002;</p>
</li>
<li><p>&#x521D;&#x6B65;&#x641C;&#x7D22;&#x7684;&#x7ED3;&#x679C;&#x4E2D;&#xFF0C;&#x53EF;&#x4EE5;&#x63D0;&#x53D6;&#x7248;&#x672C;&#x53F7;&#x3002;&#x793A;&#x4F8B;&#x4E2D;&#xFF0C;ZeroMQ&#x5934;&#x6587;&#x4EF6;&#x5305;&#x542B;&#x5E93;&#x7248;&#x672C;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x5B57;&#x7B26;&#x4E32;&#x64CD;&#x4F5C;&#x548C;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x63D0;&#x53D6;&#x5E93;&#x7248;&#x672C;&#x4FE1;&#x606F;&#x3002;</p>
</li>
<li><p>&#x6700;&#x540E;&#xFF0C;&#x8C03;&#x7528;<code>find_package_handle_standard_args</code>&#x547D;&#x4EE4;&#x3002;&#x5904;&#x7406;<code>find_package</code>&#x547D;&#x4EE4;&#x7684;<code>REQUIRED</code>&#x3001;<code>QUIET</code>&#x548C;&#x7248;&#x672C;&#x53C2;&#x6570;&#xFF0C;&#x5E76;&#x8BBE;&#x7F6E;<code>ZeroMQ_FOUND</code>&#x53D8;&#x91CF;&#x3002;</p>
</li>
</ol>
<p><strong>NOTE</strong>:<em>&#x4EFB;&#x4F55;CMake&#x547D;&#x4EE4;&#x7684;&#x5B8C;&#x6574;&#x6587;&#x6863;&#x90FD;&#x53EF;&#x4EE5;&#x4ECE;&#x547D;&#x4EE4;&#x884C;&#x83B7;&#x5F97;&#x3002;&#x4F8B;&#x5982;&#xFF0C;<code>cmake --help-command find_file</code>&#x5C06;&#x8F93;&#x51FA;<code>find_file</code>&#x547D;&#x4EE4;&#x7684;&#x624B;&#x518C;&#x9875;&#x3002;&#x5BF9;&#x4E8E;CMake&#x6807;&#x51C6;&#x6A21;&#x5757;&#x7684;&#x624B;&#x518C;&#xFF0C;&#x53EF;&#x4EE5;&#x5728;CLI&#x4F7F;&#x7528;<code>--help-module</code>&#x770B;&#x5230;&#x3002;&#x4F8B;&#x5982;&#xFF0C;<code>cmake --help-module FindPackageHandleStandardArgs</code>&#x5C06;&#x8F93;&#x51FA;<code>FindPackageHandleStandardArgs.cmake</code>&#x7684;&#x624B;&#x518C;&#x9875;&#x9762;&#x3002;</em></p>
<h2 id="&#x66F4;&#x591A;&#x4FE1;&#x606F;">&#x66F4;&#x591A;&#x4FE1;&#x606F;</h2>
<p>&#x603B;&#x800C;&#x8A00;&#x4E4B;&#xFF0C;&#x6709;&#x56DB;&#x79CD;&#x65B9;&#x5F0F;&#x53EF;&#x7528;&#x4E8E;&#x627E;&#x5230;&#x4F9D;&#x8D56;&#x5305;:</p>
<ol>
<li>&#x4F7F;&#x7528;&#x7531;&#x5305;&#x4F9B;&#x5E94;&#x5546;&#x63D0;&#x4F9B;CMake&#x6587;&#x4EF6;<code>&lt;package&gt;Config.cmake</code> &#xFF0C;<code>&lt;package&gt;ConfigVersion.cmake</code>&#x548C;<code>&lt;package&gt;Targets.cmake</code>&#xFF0C;&#x901A;&#x5E38;&#x4F1A;&#x5728;&#x5305;&#x7684;&#x6807;&#x51C6;&#x5B89;&#x88C5;&#x4F4D;&#x7F6E;&#x67E5;&#x627E;&#x3002;</li>
<li>&#x65E0;&#x8BBA;&#x662F;&#x7531;CMake&#x8FD8;&#x662F;&#x7B2C;&#x4E09;&#x65B9;&#x63D0;&#x4F9B;&#x7684;&#x6A21;&#x5757;&#xFF0C;&#x4E3A;&#x6240;&#x9700;&#x5305;&#x4F7F;&#x7528;<code>find-module</code>&#x3002;</li>
<li>&#x4F7F;&#x7528;<code>pkg-config</code>&#xFF0C;&#x5982;&#x672C;&#x8282;&#x7684;&#x793A;&#x4F8B;&#x6240;&#x793A;&#x3002;</li>
<li>&#x5982;&#x679C;&#x8FD9;&#x4E9B;&#x90FD;&#x4E0D;&#x53EF;&#x884C;&#xFF0C;&#x90A3;&#x4E48;&#x7F16;&#x5199;&#x81EA;&#x5DF1;&#x7684;<code>find</code>&#x6A21;&#x5757;&#x3002;</li>
</ol>
<p>&#x8FD9;&#x56DB;&#x79CD;&#x53EF;&#x9009;&#x65B9;&#x6848;&#x6309;&#x76F8;&#x5173;&#x6027;&#x8FDB;&#x884C;&#x4E86;&#x6392;&#x5E8F;&#xFF0C;&#x6BCF;&#x79CD;&#x65B9;&#x6CD5;&#x4E5F;&#x90FD;&#x6709;&#x5176;&#x6311;&#x6218;&#x3002;</p>
<p>&#x76EE;&#x524D;&#xFF0C;&#x5E76;&#x4E0D;&#x662F;&#x6240;&#x6709;&#x7684;&#x5305;&#x4F9B;&#x5E94;&#x5546;&#x90FD;&#x63D0;&#x4F9B;CMake&#x7684;Find&#x6587;&#x4EF6;&#xFF0C;&#x4E0D;&#x8FC7;&#x6B63;&#x53D8;&#x5F97;&#x8D8A;&#x6765;&#x8D8A;&#x666E;&#x904D;&#x3002;&#x56E0;&#x4E3A;&#x5BFC;&#x51FA;CMake&#x76EE;&#x6807;&#xFF0C;&#x4F7F;&#x5F97;&#x7B2C;&#x4E09;&#x65B9;&#x4EE3;&#x7801;&#x5F88;&#x5BB9;&#x6613;&#x4F7F;&#x7528;&#x5B83;&#x6240;&#x4F9D;&#x8D56;&#x7684;&#x5E93;&#x548C;/&#x6216;&#x7A0B;&#x5E8F;&#x9644;&#x52A0;&#x7684;&#x4F9D;&#x8D56;&#x3002;</p>
<p>&#x4ECE;&#x4E00;&#x5F00;&#x59CB;&#xFF0C;<code>Find-module</code>&#x5C31;&#x4E00;&#x76F4;&#x662F;CMake&#x4E2D;&#x5B9A;&#x4F4D;&#x4F9D;&#x8D56;&#x7684;&#x4E3B;&#x6D41;&#x624B;&#x6BB5;&#x3002;&#x4F46;&#x662F;&#xFF0C;&#x5B83;&#x4EEC;&#x4E2D;&#x7684;&#x5927;&#x591A;&#x6570;&#x4ECD;&#x7136;&#x4F9D;&#x8D56;&#x4E8E;&#x8BBE;&#x7F6E;&#x4F9D;&#x8D56;&#x9879;&#x4F7F;&#x7528;&#x7684;&#x53D8;&#x91CF;&#xFF0C;&#x6BD4;&#x5982;<code>Boost_INCLUDE_DIRS</code>&#x3001;<code>PYTHON_INTERPRETER</code>&#x7B49;&#x7B49;&#x3002;&#x8FD9;&#x79CD;&#x65B9;&#x5F0F;&#x5F88;&#x96BE;&#x5728;&#x7B2C;&#x4E09;&#x65B9;&#x53D1;&#x5E03;&#x81EA;&#x5DF1;&#x7684;&#x5305;&#x65F6;&#xFF0C;&#x786E;&#x4FDD;&#x4F9D;&#x8D56;&#x5173;&#x7CFB;&#x88AB;&#x6EE1;&#x8DB3;&#x3002;</p>
<p>&#x4F7F;&#x7528;<code>pkg-config</code>&#x7684;&#x65B9;&#x6CD5;&#x53EF;&#x4EE5;&#x5F88;&#x597D;&#x5730;&#x8FDB;&#x884C;&#x9002;&#x914D;&#xFF0C;&#x56E0;&#x4E3A;&#x5B83;&#x5DF2;&#x7ECF;&#x6210;&#x4E3A;Unix&#x7CFB;&#x7EDF;&#x7684;&#x6807;&#x51C6;&#x3002;&#x7136;&#x800C;&#xFF0C;&#x4E5F;&#x7531;&#x4E8E;&#x8FD9;&#x4E2A;&#x539F;&#x56E0;&#xFF0C;&#x5B83;&#x4E0D;&#x662F;&#x4E00;&#x4E2A;&#x5B8C;&#x5168;&#x8DE8;&#x5E73;&#x53F0;&#x7684;&#x65B9;&#x6CD5;&#x3002;&#x6B64;&#x5916;&#xFF0C;&#x5982;CMake&#x6587;&#x6863;&#x6240;&#x8FF0;&#xFF0C;&#x5728;&#x67D0;&#x4E9B;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x7528;&#x6237;&#x53EF;&#x80FD;&#x4F1A;&#x610F;&#x5916;&#x5730;&#x8986;&#x76D6;&#x68C0;&#x6D4B;&#x5305;&#xFF0C;&#x5E76;&#x5BFC;&#x81F4;<code>pkg-config</code>&#x63D0;&#x4F9B;&#x4E0D;&#x6B63;&#x786E;&#x7684;&#x4FE1;&#x606F;&#x3002;</p>
<p>&#x6700;&#x540E;&#x7684;&#x65B9;&#x6CD5;&#x662F;&#x7F16;&#x5199;&#x81EA;&#x5DF1;&#x7684;&#x67E5;&#x627E;&#x6A21;&#x5757;&#x811A;&#x672C;&#xFF0C;&#x5C31;&#x50CF;&#x672C;&#x793A;&#x4F8B;&#x4E2D;&#x90A3;&#x6837;&#x3002;&#x8FD9;&#x662F;&#x53EF;&#x884C;&#x7684;&#xFF0C;&#x5E76;&#x4E14;&#x4F9D;&#x8D56;&#x4E8E;<code>FindPackageHandleStandardArgs.cmake</code>&#x3002;&#x7136;&#x800C;&#xFF0C;&#x7F16;&#x5199;&#x4E00;&#x4E2A;&#x5168;&#x9762;&#x7684;&#x67E5;&#x627E;&#x6A21;&#x5757;&#x811A;&#x672C;&#x7EDD;&#x975E;&#x6613;&#x4E8B;&#xFF1B;&#x6709;&#x9700;&#x8981;&#x8003;&#x8651;&#x5F88;&#x591A;&#x53EF;&#x80FD;&#x6027;&#xFF0C;&#x6211;&#x4EEC;&#x5728;Unix&#x548C;Windows&#x5E73;&#x53F0;&#x4E0A;&#xFF0C;&#x4E3A;&#x67E5;&#x627E;ZeroMQ&#x5E93;&#x6587;&#x4EF6;&#x6F14;&#x793A;&#x4E86;&#x4E00;&#x4E2A;&#x4F8B;&#x5B50;&#x3002;</p>
<p>&#x6240;&#x6709;&#x8F6F;&#x4EF6;&#x5F00;&#x53D1;&#x4EBA;&#x5458;&#x90FD;&#x975E;&#x5E38;&#x6E05;&#x695A;&#x8FD9;&#x4E9B;&#x95EE;&#x9898;&#x548C;&#x56F0;&#x96BE;&#xFF0C;&#x6B63;&#x5982;CMake&#x90AE;&#x4EF6;&#x5217;&#x8868;&#x4E0A;&#x8BA8;&#x8BBA;&#x6240;&#x793A;: <a href="https://cmake.org/pipermail/cmake/2018-May/067556.html" target="_blank">https://cmake.org/pipermail/cmake/2018-May/067556.html</a> &#x3002;<code>pkg-config</code>&#x5728;Unix&#x5305;&#x5F00;&#x53D1;&#x4EBA;&#x5458;&#x4E2D;&#x662F;&#x53EF;&#x4EE5;&#x63A5;&#x53D7;&#x7684;&#xFF0C;&#x4F46;&#x662F;&#x5B83;&#x4E0D;&#x80FD;&#x5F88;&#x5BB9;&#x6613;&#x5730;&#x79FB;&#x690D;&#x5230;&#x975E;Unix&#x5E73;&#x53F0;&#x3002;CMake&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x529F;&#x80FD;&#x5F3A;&#x5927;&#xFF0C;&#x4F46;&#x5E76;&#x975E;&#x6240;&#x6709;&#x8F6F;&#x4EF6;&#x5F00;&#x53D1;&#x4EBA;&#x5458;&#x90FD;&#x719F;&#x6089;CMake&#x8BED;&#x6CD5;&#x3002;&#x516C;&#x5171;&#x5305;&#x89C4;&#x8303;&#x9879;&#x76EE;&#x662F;&#x7EDF;&#x4E00;&#x7528;&#x4E8E;&#x5305;&#x67E5;&#x627E;&#x7684;<code>pkg-config</code>&#x548C;CMake&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x65B9;&#x6CD5;&#x7684;&#x6700;&#x65B0;&#x5C1D;&#x8BD5;&#x3002;&#x60A8;&#x53EF;&#x4EE5;&#x5728;&#x9879;&#x76EE;&#x7684;&#x7F51;&#x7AD9;&#x4E0A;&#x627E;&#x5230;&#x66F4;&#x591A;&#x4FE1;&#x606F;: <a href="https://mwoehlke.github.io/cps/" target="_blank">https://mwoehlke.github.io/cps/</a></p>
<p>&#x5728;&#x7B2C;10&#x7AE0;&#x4E2D;&#x5C06;&#x8BA8;&#x8BBA;&#xFF0C;&#x5982;&#x4F55;&#x4F7F;&#x7528;&#x524D;&#x9762;&#x8BA8;&#x8BBA;&#x4E2D;&#x6982;&#x8FF0;&#x7684;&#x7B2C;&#x4E00;&#x79CD;&#x65B9;&#x6CD5;&#xFF0C;&#x4F7F;&#x7B2C;&#x4E09;&#x65B9;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#xFF0C;&#x627E;&#x5230;&#x81EA;&#x5DF1;&#x7684;&#x5305;&#xFF1A;&#x4E3A;&#x9879;&#x76EE;&#x63D0;&#x4F9B;&#x81EA;&#x5DF1;&#x7684;CMake&#x67E5;&#x627E;&#x6587;&#x4EF6;&#x3002;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="3.9-chinese.html" class="navigation navigation-prev " aria-label="Previous page: 3.9 检测外部库:Ⅰ. 使用pkg-config">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../chapter4/4.0-chinese.html" class="navigation navigation-next " aria-label="Next page: 第4章 创建和运行测试">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"3.10 检测外部库:Ⅱ. 自定义find模块","level":"1.6.10","depth":2,"next":{"title":"第4章 创建和运行测试","level":"1.7","depth":1,"path":"content/chapter4/4.0-chinese.md","ref":"content/chapter4/4.0-chinese.md","articles":[{"title":"4.1 创建一个简单的单元测试","level":"1.7.1","depth":2,"path":"content/chapter4/4.1-chinese.md","ref":"content/chapter4/4.1-chinese.md","articles":[]},{"title":"4.2 使用Catch2库进行单元测试","level":"1.7.2","depth":2,"path":"content/chapter4/4.2-chinese.md","ref":"content/chapter4/4.2-chinese.md","articles":[]},{"title":"4.3 使用Google Test库进行单元测试","level":"1.7.3","depth":2,"path":"content/chapter4/4.3-chinese.md","ref":"content/chapter4/4.3-chinese.md","articles":[]},{"title":"4.4 使用Boost Test进行单元测试","level":"1.7.4","depth":2,"path":"content/chapter4/4.4-chinese.md","ref":"content/chapter4/4.4-chinese.md","articles":[]},{"title":"4.5 使用动态分析来检测内存缺陷","level":"1.7.5","depth":2,"path":"content/chapter4/4.5-chinese.md","ref":"content/chapter4/4.5-chinese.md","articles":[]},{"title":"4.6 预期测试失败","level":"1.7.6","depth":2,"path":"content/chapter4/4.6-chinese.md","ref":"content/chapter4/4.6-chinese.md","articles":[]},{"title":"4.7 使用超时测试运行时间过长的测试","level":"1.7.7","depth":2,"path":"content/chapter4/4.7-chinese.md","ref":"content/chapter4/4.7-chinese.md","articles":[]},{"title":"4.8 并行测试","level":"1.7.8","depth":2,"path":"content/chapter4/4.8-chinese.md","ref":"content/chapter4/4.8-chinese.md","articles":[]},{"title":"4.9 运行测试子集","level":"1.7.9","depth":2,"path":"content/chapter4/4.9-chinese.md","ref":"content/chapter4/4.9-chinese.md","articles":[]},{"title":"4.10 使用测试固件","level":"1.7.10","depth":2,"path":"content/chapter4/4.10-chinese.md","ref":"content/chapter4/4.10-chinese.md","articles":[]}]},"previous":{"title":"3.9 检测外部库:Ⅰ. 使用pkg-config","level":"1.6.9","depth":2,"path":"content/chapter3/3.9-chinese.md","ref":"content/chapter3/3.9-chinese.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-lunr","-search","search-pro","-sharing","github","pageview-count"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"github":{"url":"https://github.com/arcticfox1919"},"search-pro":{},"pageview-count":{},"highlight":{},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"陈晓伟 chenxiaowei","pdf":{"pageNumbers":false,"fontSize":30,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":30,"left":30,"top":30,"bottom":50}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"《CMake Cookbook》中文版","language":"zh-hans","gitbook":"*","description":"作为对《CMake Cookbook》英文版的中文翻译。","direction":"ltr"},"file":{"path":"content/chapter3/3.10-chinese.md","mtime":"2020-09-22T10:39:01.932Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-09-22T11:21:21.825Z"},"basePath":"../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../gitbook/gitbook.js"></script>
    <script src="../../gitbook/theme.js"></script>
    
        
        <script src="../../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
        
    
        
        <script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

